package demo.modbus.config;

import com.serotonin.modbus4j.ModbusFactory;
import com.serotonin.modbus4j.ModbusSlaveSet;
import demo.modbus.dto.HoldingRegisterHandle;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by leohe on 2018/6/21.
 */
@Configuration
public class ModbusSalveConfig {

    @Bean
    public ModbusSlaveSet initModbusSlaveSet(){
        ModbusFactory modbusFactory = new ModbusFactory();
        final ModbusSlaveSet listener = modbusFactory.createTcpSlave(false);
        //listener.addProcessImage(getModscanProcessImage(1));
        return listener;
    }

    @Bean
    public HoldingRegisterHandle HoldingRegisterHandle(){
        return new HoldingRegisterHandle();
    }

}
